package com.ruoyi.web.controller.qsng;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.qsng.domain.TRefund;
import com.ruoyi.qsng.service.ITRefundService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 退款记录Controller
 * 
 * @author gk
 * @date 2023-07-18
 */
@RestController
@RequestMapping("/system/refund")
@Api(tags = "pc--退款")
public class TRefundController extends BaseController
{
    @Autowired
    private ITRefundService tRefundService;

    /**
     * 查询退款记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:refund:list')")
    @GetMapping("/list")
    @ApiOperation(value = "查询退款记录列表 system:refund:list")
    public TableDataInfo list(TRefund tRefund)
    {
        startPage();
        List<TRefund> list = tRefundService.selectTRefundList(tRefund);
        return getDataTable(list);
    }

    /**
     * 导出退款记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:refund:export')")
    @Log(title = "退款记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation(value = "导出退款记录列表")
    public void export(HttpServletResponse response, TRefund tRefund)
    {
        List<TRefund> list = tRefundService.selectTRefundList(tRefund);
        ExcelUtil<TRefund> util = new ExcelUtil<TRefund>(TRefund.class);
        util.exportExcel(response, list, "退款记录数据");
    }

    /**
     * 获取退款记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:refund:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation(value = "获取退款记录详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {

        return success(tRefundService.selectTRefundById(id));
    }

    /**
     * 新增退款记录
     */
    @PreAuthorize("@ss.hasPermi('system:refund:add')")
    @Log(title = "退款记录", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation(value = "新增退款记录")
    public AjaxResult add(@RequestBody TRefund tRefund)
    {

        return toAjax(tRefundService.insertTRefund(tRefund));
    }

    /**
     * 修改退款记录
     */
    @PreAuthorize("@ss.hasPermi('system:refund:edit')")
    @Log(title = "退款记录", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation(value = "修改退款记录")
    public AjaxResult edit(@RequestBody TRefund tRefund)
    {

        return toAjax(tRefundService.updateTRefund(tRefund));
    }

    /**
     * 删除退款记录
     */
    @PreAuthorize("@ss.hasPermi('system:refund:remove')")
    @Log(title = "退款记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @ApiOperation(value = "删除退款记录")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tRefundService.deleteTRefundByIds(ids));
    }
}
